$(function () {

    google_map({html: $('#detail-address').val(), latitude: $('#detail-latitude').val(), longitude: $('#detail-longitude').val(), src_icon: center_icon});
    
    
    // Get the distance from current location
    $('.distance .km').html('...');
    navigator.geolocation.getCurrentPosition(function (position) {
        var pos = position.coords;
        var km = measure($('#detail-latitude').val(), $('#detail-longitude').val(), pos.latitude, pos.longitude);   
        $('.distance .km').html(km+ ' km');

        get_address(pos.latitude, pos.longitude, function (res) {
            if (! $('#from-place').val()) {
                $('#from-place').val(res.address);
            }
        });
    });
});
